package com.xurui.kotlindelegate

import android.content.Context
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity

/**
 * Created by pengxr on 7/5/2021
 */
class OrderDetailActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_order_detail)

        val orderId = intent.getIntExtra(ARG_ORDER_ID, 0)
        val orderType = intent.getIntExtra(ARG_ORDER_TYPE, 0)

        with(supportFragmentManager.beginTransaction()) {
            val fragment = OrderDetailFragment.get(orderId, orderType)
            add(R.id.containerId, fragment)
            commit()
        }

        OrderDetailDialogFragment().show(supportFragmentManager, "")
    }

    companion object {
        private const val ARG_ORDER_ID = "orderId"
        private const val ARG_ORDER_TYPE = "orderType"

        fun start(
            context: Context,
            orderId: Int,
            orderType: Int?
        ) {
            val args = Bundle()
            args.putInt(ARG_ORDER_ID, orderId)
            args.putInt(ARG_ORDER_TYPE, orderType ?: 2)
            context.start<OrderDetailActivity>(args)
        }
    }
}